package com.ssm.hyl.server;

import com.hyl.ssm.entity.Role;
import com.hyl.ssm.mapper.RoleMapper;
import com.hyl.ssm.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * RoleService
 *
 * @author hyl
 * @date 2024-12-13
 */
public class RoleService {

    RoleMapper roleMapper;

    public Role findAll(){
        roleMapper = MyBatisUtil.createSqlSession().getMapper(RoleMapper.class);
       return roleMapper.selectRoleById(1);

    }

    public int insert( Role role){
        SqlSession session = MyBatisUtil.createSqlSession();
        try {
            session.getMapper(RoleMapper.class).insetRole(role);
            session.commit();
        }catch (Exception e){
            session.rollback();
        }finally {
            session.close();
        }
        return 1;
    }
}
